package com.my.controller;


import com.my.bean.MenuEvaluate;

import com.my.bean.Variety;
import com.my.service.MenuEvaluateService;
import com.my.service.VarietyService;
import com.my.util.SessionUtil;
import org.apache.log4j.Logger;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * <p>
 * 客户每日餐单统计 前端控制器
 * </p>
 *
 * @author 崔倩倩
 * @since 2018-08-31
 */
@Controller
@RequestMapping("/menuEvaluate")
public class MenuEvaluateController {
    @Autowired
    MenuEvaluateService menuEvaluateService;
    @Autowired
    VarietyService varietyService;

    Logger logger = Logger.getLogger(WorkguidaceController.class);

    /**
     * 添加
     * @return
     */

    @RequestMapping("addMenuEvaluate")
    @ResponseBody
    public boolean addMenuEvaluate(MenuEvaluate menuEvaluate){
    menuEvaluate.setStar(1);
        if (menuEvaluateService.insert(menuEvaluate)){
            logger.info("{addEvaluate|添加成功}");
        }else{
            logger.info("{addEvaluate|添加失败}");
        }
        return true;
    }

    /* 查询*/
    @RequestMapping("/selectMenuEvaluate")
    @ResponseBody
    public List<MenuEvaluate> selectMenuEvaluate(HttpSession session) {
        boolean admin=false;
        //如果事超级管理员  即可查看所有的房间  判断是否为超级管理员
        if(SessionUtil.getSessionUser(session).getRoles().getRoleValue().equals("9f77d5a8-75c6-4d06-adf9-a37e727d491a")){
            admin=true;
        }
        List<MenuEvaluate> list = menuEvaluateService.selectMenuEvaluate();
        return list;
    }

    // 查询
    @RequestMapping("/findAllVariety")
    @ResponseBody
    public List<Variety> findAllVariety() {
        Map map = new HashMap();
        return varietyService.selectByMap(map);
    }

   //  图表
    @RequestMapping("/countMenuEvaluateStar")
    @ResponseBody
    public List<Map> countMenuEvaluateStar(HttpSession session) {
        boolean admin=false;
        //如果事超级管理员  即可查看所有的房间  判断是否为超级管理员
        if(SessionUtil.getSessionUser(session).getRoles().getRoleValue().equals("9f77d5a8-75c6-4d06-adf9-a37e727d491a")){
            admin=true;
        }

       return menuEvaluateService.countMenuEvaluateStar();
    }


    @RequestMapping("/MenuEvaluates")
    public String MenuEvaluates(){
        return "Customer_menu";
    }
}
